#ifndef __WIZ_BNF_PARSER_IMPL_HPP__SHANHAOBO_19800429__
#define __WIZ_BNF_PARSER_IMPL_HPP__SHANHAOBO_19800429__

#include "../../Base/WizBase.hpp"

#include "../WizBNFPolicies.hpp"

namespace Wiz
{
    namespace BNF
    {
        namespace Parser
        {
            namespace Impl
            {
                //////////////////////////////////////////////////////////////////////////
                ///======================ContiguousParserParse=========================///
                //////////////////////////////////////////////////////////////////////////
                template <typename ResultT, typename ParserT, typename ScannerT, typename BaseT>
                WIZ_INLINE ResultT ContiguousParserParse(
                    ParserT const& InParse,
                    ScannerT const& Scan,
                    ::Wiz::BNF::Policy::Skipper::Iteration::Type<BaseT> const&)
                {
                    typedef ::Wiz::BNF::Policy::Scanner<
                        ::Wiz::BNF::Policy::NoSkipper::Iteration::Type<typename ScannerT::tIterationPolicy>,
                        typename ScannerT::tMatchPolicy,
                        typename ScannerT::tActionPolicy
                    > tPolicies;

                    Scan.Skip(Scan);
                    ResultT hit = InParse.Parse(Scan.ChangePolicies(tPolicies(Scan)));
                    // We will not do a post skip!!!
                    return hit;
                }

                template <typename ResultT, typename ParserT, typename ScannerT, typename BaseT>
                WIZ_INLINE ResultT ContiguousParserParse(
                    ParserT const& InParse,
                    ScannerT const& Scan,
                    ::Wiz::BNF::Policy::NoSkipper::Iteration::Type<BaseT> const&)
                {
                    return InParse.Parse(Scan);
                }

                template <typename ResultT, typename ParserT, typename ScannerT>
                WIZ_INLINE ResultT ContiguousParserParse(
                    ParserT const& InParse,
                    ScannerT const& Scan,
                    ::Wiz::BNF::Policy::Iteration const&)
                {
                    return InParse.Parse(Scan);
                }
                //////////////////////////////////////////////////////////////////////////
                ///======================ContiguousParserParse=========================///
                //////////////////////////////////////////////////////////////////////////


                //////////////////////////////////////////////////////////////////////////
                ///========================ImplicitLexemeParse=========================///
                //////////////////////////////////////////////////////////////////////////
                template <typename ResultT, typename ParserT, typename ScannerT, typename BaseT>
                WIZ_INLINE ResultT ImplicitLexemeParse(
                    ParserT const& InParse,
                    ScannerT const& Scan,
                    ::Wiz::BNF::Policy::Skipper::Iteration::Type<BaseT> const&)
                {
                    typedef ::Wiz::BNF::Policy::Scanner<
                        ::Wiz::BNF::Policy::NoSkipper::Iteration::Type<typename ScannerT::tIterationPolicy>,
                        typename ScannerT::tMatchPolicy,
                        typename ScannerT::tActionPolicy
                    > tPolicies;

                    Scan.Skip(Scan);
                    ResultT hit = InParse.ParseMain(Scan.ChangePolicies(tPolicies(Scan)));
                    // We will not do a post skip!!!
                    return hit;
                }

                template <typename ResultT, typename ParserT, typename ScannerT, typename BaseT>
                WIZ_INLINE ResultT ImplicitLexemeParse(
                    ParserT const& InParse,
                    ScannerT const& Scan,
                    ::Wiz::BNF::Policy::NoSkipper::Iteration::Type<BaseT> const&)
                {
                    return InParse.ParseMain(Scan);
                }

                template <typename ResultT, typename ParserT, typename ScannerT>
                WIZ_INLINE ResultT ImplicitLexemeParse(
                    ParserT const& InParse,
                    ScannerT const& Scan,
                    ::Wiz::BNF::Policy::Iteration const&)
                {
                    return InParse.ParseMain(Scan);
                }
                //////////////////////////////////////////////////////////////////////////
                ///========================ImplicitLexemeParse=========================///
                //////////////////////////////////////////////////////////////////////////
            } /// end of namespace Impl
        } /// end of namespace Parser
    } /// end of namespace BNF
} /// end of namespace Wiz

#endif /*__WIZ_BNF_PARSER_IMPL_HPP__SHANHAOBO_19800429__*/
